package com.spartez.farhorizons.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.MessageBox.PromptCallback;
import com.spartez.farhorizons.client.DataService.GravityTechLevelListener;

public class GraviticsPanel extends HTML implements GravityTechLevelListener, ClickHandler {
	public GraviticsPanel() {
		setWordWrap(false);
		gravityTechLevel(FarHorizons.dataService.getCurrentGravity());
		FarHorizons.dataService.registerGravityTechLevelListener(this);
		addClickHandler(this);
	}

	public void gravityTechLevel(int gravity) {
		setHTML("Gravitics: " + gravity + " (<a>change</a>)");
	}

	public void onClick(ClickEvent event) {
		MessageBox.prompt("Gravitics TechLevel", "Enter your current Gravitics techlevel", new PromptCallback() {

			public void execute(String btnID, String text) {
				if (btnID.equals("ok")) {
					FarHorizons.dataService.setGravityTechLevel(Integer.valueOf(text));
				}
			}
			
		});
	}
	
}
